package com.nkzy.pojo;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class Result<T> {
    private boolean success;
    private String message;
    private T data;
    //类中static表示静态的方法，不需要创建对象，直接调用类名+点
    //成功，有数据

    public static <T> Result<T> success(T data) {
        return Result.<T>builder()
                .success(true)
                .message("操作成功")
                .data(data)
                .build();
    }
//失败
    public static <T> Result<T> success(String message, T data) {
        return Result.<T>builder()
                .success(true)
                .message(message)
                .data(data)
                .build();
    }

    public static <T> Result<T> error(String message) {
        return Result.<T>builder()
                .success(false)
                .message(message)
                .build();
    }

    public static <T> Result<T> error(String message, T data) {
        return Result.<T>builder()
                .success(false)
                .message(message)
                .data(data)
                .build();
    }
}
